﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iLangl.Model;
using System.Threading;
using iLangl.BusinessModel.Managers;

namespace iLangl.BusinessModel.Actions.Push
{
	public class SyncTranslationProviderSettings : BaseSecurityAction
	{
		public SyncTranslationProviderSettings()
		{
			SettingsForTPResponseContext context = new SettingsForTPResponseContext();
			ResponseContext = context;
			context.ContextUpdated += new EventHandler(context_ContextUpdated);
			isSynced = true;
		}

		void context_ContextUpdated(object sender, EventArgs e)
		{
			object result = ResponseContext.GetContext();

			if (result is SettingsFromTP)
			{
				settings = (SettingsFromTP)result;
				weGetResult();
			}
		}


		private SettingsFromTP settings;
		public SettingsFromTP Settings
		{
			get
			{
				return settings;
			}
		}
		protected override string GetName()
		{
			return "SyncSettings";
		}
		protected override void _execute()
		{
			PluginLicense license = PluginManager.Instance.GetLicense(PluginLiceneKey);

			SettingsManager.Instance.UpdateTPSettings(license, Settings);
		}

		protected override string GetVersion()
		{
			return "1";
		}
	}

}
